package io;

import java.io.*;
import java.nio.charset.StandardCharsets;
import java.util.Scanner;

/**
 *
 */
public class PWDemo2 {
    public static void main(String[] args) throws FileNotFoundException {
        Scanner s = new Scanner(System.in);
        FileOutputStream fos = new FileOutputStream("pw.txt");
        OutputStreamWriter outputStreamWriter = new OutputStreamWriter(fos, StandardCharsets.UTF_8);
        BufferedWriter bw = new BufferedWriter(outputStreamWriter);
        PrintWriter pw = new PrintWriter(bw, true);
        System.out.println("开始写吧");
        while (true) {
            String line = s.nextLine();
            if ("exit".equals(line)) {
                System.out.println("写完了");
                break;
            }
            pw.println(line);
        }
        pw.close();

    }
}
